.config-page {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
  min-height: calc(100vh - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.config-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
.config-header .ant-btn {
  background: var(--color-primary) !important;
  color: white !important;
}
.config-header .ant-btn:hover {
  background: var(--color-primary) !important;
  color: white !important;
}
.config-header h2 {
  margin: 0;
  color: var(--color-text-primary);
}

.header-buttons {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.header-buttons button {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border: none;
 
  border-radius: var(--border-radius-small);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}


.header-buttons button:hover {
  background: var(--color-primary-dark);
}

.header-buttons .save-button {
  padding: 8px;
}

.header-buttons .save-button.has-changes {
  animation: pulse 2s infinite;
}

.header-buttons .import-button,
.header-buttons .export-button {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.header-buttons .import-button:hover,
.header-buttons .export-button:hover {
  background: var(--color-card-bg);
  border-color: var(--color-primary);
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.save-button {
  position: fixed;
  right: 32px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  cursor: not-allowed;
  opacity: 0.6;
  transition: all 0.3s;
  box-shadow: 0 2px 8px var(--color-shadow);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-card-button {
  position: fixed;
  right: 32px;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  transition: all 0.3s;
  box-shadow: 0 2px 8px var(--color-shadow);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.save-button.has-changes {
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  opacity: 1;
}

.save-button.has-changes:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--color-shadow);
}

.add-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--border-radius-small);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  transition: background-color 0.3s;
}

.add-button:hover {
  background: var(--color-primary-dark);
}

.config-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 1;
}

.config-item {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-medium);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-all;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.item-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title svg {
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.delete-button {
  padding: 6px;
  border: none;
  border-radius: var(--border-radius-small);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
}

.delete-button:hover {
  background: var(--color-error);
  color: white;
}

.item-content {
  padding: 16px;
  max-width: 100%;
  overflow: hidden;
  word-wrap: break-word;
  box-sizing: border-box;
}

.item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.item-actions .preview-button {
  padding: 6px;
  border: none;
  border-radius: var(--border-radius-small);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-actions .preview-button:hover {
  background: var(--color-primary);
  color: white;
}

.visibility-toggle {
  padding: 6px;
  border: none;
  border-radius: var(--border-radius-small);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visibility-toggle:hover {
  background: var(--color-background);
  color: var(--color-primary);
}

.visibility-toggle.hidden {
  color: var(--color-text-light);
  opacity: 0.5;
}

.visibility-toggle.hidden:hover {
  color: var(--color-primary);
  opacity: 1;
}

/* 响应式布局 */
@media (min-width: 1200px) {
  .config-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .config-page {
    padding: 16px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
    overflow-x: hidden;
    width: 100%;
  }
  
  .config-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 24px;
    max-width: 100%;
    width: 100%;
  }

  .header-left {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    text-align: center;
  }

  .version-info {
    margin-top: 12px;
    display: inline-flex;
    justify-content: center;
    margin: 0;
    padding: 6px 12px;
    max-width: fit-content;
  }
  
  .header-buttons {
    gap: 12px;
    max-width: 100%;
    width: 100%;
    padding: 0;
  }

  .header-buttons button {
    width: 100%;
    height: 44px;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
    padding: 0 16px;
    font-size: 15px;
    border-radius: 8px;
  }

  WebDAV按钮单独占一行
  .header-buttons button:last-child {
    grid-column: 1 / -1;
  }

  /* 保存按钮样式优化 */
  .save-button {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom, 20px) + 16px);
    width: 56px;
    height: 56px;
    border-radius: 28px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  .add-card-button {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom, 20px) + 86px);
    width: 56px;
    height: 56px;
    border-radius: 28px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  

  .save-button.has-changes:hover {
    transform: none;
  }

  .config-list {
    grid-template-columns: 1fr;
    max-width: 100%;
    width: 100%;
    margin-bottom: env(safe-area-inset-bottom, 20px);
  }
  
  .item-content {
    padding: 8px;
    max-width: 100%;
    overflow: hidden;
    width: 100%;
  }

  .item-header {
    padding: 8px 12px;
    width: 100%;
  }

  .item-title {
    font-size: 14px;
    flex: 1;
    min-width: 0;
  }

  .item-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .item-actions button {
    padding: 4px;
  }
  
  .preview-container {
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .close-preview {
    top: env(safe-area-inset-top, 20px);
    right: 12px;
  }

  /* 优化表单字段在移动端的显示 */
  .config-field {
    margin-bottom: 12px;
    width: 100%;
  }

  .config-field label {
    font-size: 13px;
    width: 100%;
  }

  .config-field input,
  .config-field .ant-input,
  .config-field .ant-select {
    font-size: 14px;
    padding: 6px 10px;
    width: 100%;
    box-sizing: border-box;
  }

  /* 优化按钮组在移动端的显示 */
  .modal-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .modal-buttons button {
    width: 100%;
  }

  /* 优化 WebDAV 配置表单在移动端的显示 */
  .ant-modal {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px) !important;
    margin: 16px !important;
  }

  .ant-modal-content {
    padding: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .ant-form-item {
    margin-bottom: 12px;
    width: 100%;
  }
}

/* 移除旧的预览按钮样式 */
.header-buttons .preview-button {
  display: none;
}

.preview-container {
  position: fixed;
  top: 80px;
  right: 100px;
  width: 400px;
  height: 500px;
  background: var(--color-card-bg);
  border-radius: var(--border-radius-medium);
  box-shadow: 0 4px 12px var(--color-shadow);
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-preview {
  position: absolute;
  top: 20px;
  right: 12px;
  padding: 6px;
  border: none;
  border-radius: var(--border-radius-small);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.close-preview:hover {
  background: var(--color-error);
  color: white;
}

.preview-container.visible {
  opacity: 1;
  transform: translateX(0);
}

@media (max-width: 768px) {
  .preview-container {
    top: 20px;
    right: 20px;
    left: 20px;
    width: auto;
    height: 300px;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.version-info {
  float: right;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
  background: var(--color-background);
  padding: 4px 10px;
  border-radius: var(--border-radius-small);
  border: 1px solid var(--color-border);
  max-width: 250px;
  overflow: visible;
  white-space: nowrap;
  box-sizing: border-box;
  margin-top: 12px;
}

.version-info .ant-btn-link {
  color: var(--color-primary);
  font-size: 12px;
  height: auto;
  line-height: 1;
}

.version-info .ant-btn-link:hover {
  color: var(--color-primary-hover);
  background: var(--color-background-hover);
}

.webdav-button,
.sync-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  background-color: #4a5568;
  color: white;
  cursor: pointer;
}

.webdav-button:hover,
.sync-button:hover {
  background-color: #2d3748;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.modal-buttons button:first-child {
  background-color: #4299e1;
  color: white;
}

.modal-buttons button:last-child {
  background-color: #e2e8f0;
}
